package com.imooc.controller;

import com.imooc.pojo.bo.SubmitOrderBO;
import com.imooc.service.OrderService;
import imooc.enums.PayMethod;
import imooc.utils.ApiResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "订单接口", tags = {"订单信息展示的相关接口"})
@RestController
@RequestMapping("orders")
public class OrderController extends BaseController{

    @Autowired
    private OrderService orderService;

    /**
     * 创建订单
     * */
    @ApiOperation(value = "创建订单", notes = "创建订单", httpMethod = "POST")
    @PostMapping("/create")
    public ApiResponse create(
            @RequestBody SubmitOrderBO submitOrderBO) throws Exception {
        // 支付方式判断
        if (submitOrderBO.getPayMethod() != PayMethod.WEIXIN.type
        && submitOrderBO.getPayMethod() != PayMethod.ALIPAY.type) {
            return ApiResponse.errorMsg("支付方式不支持！");
        }
        // 1. 创建订单
        // 2. 创建订单以后，移除已经结算（已经提交）的商品
        // 3. 向支付中心发送当前订单，用于保存支付中心的订单数据
        return ApiResponse.ok();
    }


}
